<div ng-include="'components/navbar/navbar.html'"></div>

<div class="container">
  <div class="col-md-12">
    <h1 class="page-header">Dashboard</h1>
  </div>
  <div class="col-md-8">
    <p class="lead">{{meetings[0].name}}</p>
    <form ng-show="loadVote" ng-submit="createVote()" class="create-form">
      <div class="row">
        <div class="col-md-12">
          <div class="input-group">
            <input type="text" class="form-control" ng-model="voteTitle" placeholder="在这里输入投票内容">
            <span class="input-group-btn">
              <button class="btn btn-info" type="submit">保存</button>
            </span>
          </div><!-- /input-group -->
        </div>
      </div>
    </form>
    <div style="margin-top: 10px;">
      <table class="table">
        <tr>
          <th>标题</th>
          <th>同意</th>
          <th>不同意</th>
          <th>未投票</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
        <tr ng-repeat="vote in votes | filter: 'done'">
          <td>{{vote.title}}</td>
          <td>{{vote.agree}}</td>
          <td>{{vote.disagree}}</td>
          <td>{{meetings[0].actual_size- vote.agree - vote.disagree}}</td>
          <td><span class="label label-success">已完成</span></td>
          <td>&nbsp;</td>
        </tr>
        <tr ng-repeat="vote in votes | filter: 'cancel'">
          <td>{{vote.title}}</td>
          <td>{{vote.agree}}</td>
          <td>{{vote.disagree}}</td>
          <td>{{meetings[0].actual_size- vote.agree - vote.disagree}}</td>
          <td><span class="label label-warning">已取消</span></td>
          <td>&nbsp;</td>
        </tr>
        <tr ng-repeat="vote in votes | filter: 'progress'">
          <td>{{vote.title}}</td>
          <td>{{vote.agree}}</td>
          <td>{{vote.disagree}}</td>
          <td>{{meetings[0].actual_size- vote.agree - vote.disagree}}</td>
          <td>
            <span class="label label-info">进行中</span>
          </td>
          <td>
            <button class="btn btn-xs btn-link" ng-click="endVote(vote._id)">结束</button>
            <button class="btn btn-xs btn-link" ng-click="cancelVote(vote._id)">取消</button>
          </td>
        </tr>
        <tr ng-repeat="vote in votes | filter: 'wait'">
          <td>{{vote.title}}</td>
          <td>{{vote.agree}}</td>
          <td>{{vote.disagree}}</td>
          <td>{{meetings[0].actual_size- vote.agree - vote.disagree}}</td>
          <td>
            <span class="label label-default">请等待</span>
          </td>
          <td>
            <button class="btn btn-xs btn-link" ng-if="$index == 0 && meetings[0].status == 'progress'" ng-click="startVote(vote._id)">开始</button>
            <button class="btn btn-xs btn-link" ng-disabled="$index > 0" ng-if="$index > 0  && meetings[0].status == 'progress'">请等待</button>
            <button class="btn btn-xs btn-link" ng-disabled="meetings[0].status != 'progress'" ng-if="meetings[0].status == 'wait'">请等待</button>
          </td>
        </tr>
      </table>
    </div>
  </div>
  <div class="col-md-3 col-md-offset-1">
    <button class="btn btn-success full-width" ng-disabled="!votes.length || meetings[0].status == 'progress' || meetings[0].status == 'done'" ng-click="startMeeting()">开始会议</button>
    <button class="btn btn-danger full-width" ng-disabled="!votes.length || meetings[0].status == 'wait' || meetings[0].status == 'done'" ng-click="endMeeting()">结束会议</button>
    <button class="btn btn-primary full-width" ng-click="loadVote = !loadVote" ng-hide="loadVote" ng-class="{active: loadVote}" ng-disabled="meetings[0].status == 'done'">添加投票</button>
    <button class="btn btn-primary full-width" ng-click="loadVote = !loadVote" ng-show="loadVote">完成添加</button>
    <div class="panel panel-default">
      <div class="panel-heading">
        会议概述
      </div>
      <div class="panel-body">
        <p><strong>会议规模：</strong>{{meetings[0].size}} 人</p>
        <p><strong>实到人数：</strong>{{meetings[0].actual_size}} 人</p>
        <p><strong>会议日期：</strong>{{meetings[0].date | date: 'yyyy/MM/dd'}}</p>
        <p><strong>会议状态：</strong>{{meetings[0].status}}</p>
      </div>
    </div>
  </div>
</div>
